<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:rich="http://richfaces.org/rich"
	template="/templates/mainTemplate.xhtml">


	<ui:define name="windowTitle">
            #{msgs.loginTitle}
         </ui:define>
	<ui:define id="projects" name="content">
		<h:form>
			<rich:panel>

				<rich:dataTable
					onRowMouseOver="this.style.backgroundColor='#F1F1F1'"
					onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
					cellpadding="0" cellspacing="0" width="700" border="0"
					id="projectList" style="width : 100%" styleClass="tableStyle"
					rowClasses="oddRow,evenRow" headerClass="tableHeader"
					value="#{projectListBean.userProjectList}" var="projectItem">
					<f:facet name="header">
						<rich:column>
							<h:outputText styleClass="textStyle" value="List Projektów" />
						</rich:column>
						<rich:columnGroup>
							<rich:column>
								<h:outputText styleClass="headerText" value="Nazwa" />
							</rich:column>
							<rich:column>
								<h:outputText styleClass="headerText" value="Opis" />
							</rich:column>
							<rich:column>
								<h:outputText styleClass="headerText" value="Właściciel" />
							</rich:column>
							<rich:column>
								<h:outputText styleClass="headerText" value="Usuń" />
							</rich:column>
						</rich:columnGroup>
					</f:facet>

					<rich:column>
						<h:commandLink
							action="#{projectListBean.showProjectDetails(projectItem.project.id)}"
							value="#{projectItem.project.name}" />
					</rich:column>
					<rich:column>
						<h:outputText value="#{projectItem.project.description}" />
					</rich:column>
					<rich:column>
						<h:outputText value="#{projectItem.project.owner.firstName} #{projectItem.project.owner.lastName} " />
					</rich:column>
					<rich:column>
						<h:commandLink rendered="#{projectListBean.loggedUserId == projectItem.project.owner.id}" value="Usuń"
							action="#{projectListBean.deleteProject(projectItem.project)}">
						</h:commandLink>
					</rich:column>

				</rich:dataTable>


				<h:panelGroup style="display:block; text-align:center; margin: 10px">
					<h:commandButton action="#{projectListBean.goToCreateProjectSite}"
						value="#{msg.addNew}" />
				</h:panelGroup>
			</rich:panel>
			<rich:popupPanel id="popup" minHeight="200" minWidth="450"
				height="200" width="500">
				<f:facet name="header">
					<h:outputText value="Modal Panel Title" />
				</f:facet>
				<rich:panel>
				W projekcie mogą znajdować się taski. Czy na pewno chcesz go usunąć?
				</rich:panel>
				<h:panelGroup style="display:block; text-align:center; margin: 10px">
					<h:commandButton value="Tak"
						onclick="#{rich:component('popup')}.hide()"
						action="#{projectListBean.deleteProject()}" />
					<h:commandButton value="Nie" action="project"
						onclick="#{rich:component('popup')}.hide()" />
				</h:panelGroup>
			</rich:popupPanel>

		</h:form>

	</ui:define>

</ui:composition>